package com.appkubes.mall.restful.application.goods.taobao.controller;

import com.appkubes.base.core.entity.vo.PageVO;
import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.core.controller.BaseMallGoodsTaobaoController;
import com.appkubes.mall.core.entity.MallGoodsTaobao;
import com.appkubes.mall.restful.application.goods.taobao.entity.dto.GoodsTaobaoDetailsDto;
import com.appkubes.mall.restful.application.goods.taobao.entity.vo.GoodsDetailsVO;
import com.appkubes.mall.restful.application.goods.taobao.entity.vo.GoodsListVO;
import com.appkubes.mall.restful.application.goods.taobao.entity.vo.RealTimeListVO;
import com.appkubes.mall.restful.application.goods.taobao.model.GoodsTaobaoModel;
import com.appkubes.mall.restful.application.goods.taobao.service.GoodsTaobaoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "淘宝商品模块")
@RestController
@RequestMapping("/goods/taobao")
public class GoodsTaobaoController extends BaseMallGoodsTaobaoController {

    @Autowired
    private GoodsTaobaoService goodsTaobaoService;

    /**
     * 商品列表
     *
     * @param param
     * @return
     */
    @ApiOperation("商品列表")
    @PostMapping(value = "/list")
    public Response getList(@ParamValid GoodsListVO param) {
        Page<MallGoodsTaobao> pageInfo = new Page<>(param.getPage(), param.getSize());
        return Response.success(goodsTaobaoService.getList(pageInfo, param.getCid(), param.getMinPrice(), param.getMaxPrice(), param.getMinCoupon(), param.getMaxCoupon(), param.getTkRate(), param.getSort(), param.getKeyword()));
    }

    /**
     * 实时榜单
     *
     * @param realTimeListVO
     * @return
     */
    @ApiOperation("实时榜单")
    @PostMapping(value = "/rankingList")
    public Response realTimeList(@ParamValid RealTimeListVO realTimeListVO) {
        return Response.success(goodsTaobaoService.getSaleRanking(realTimeListVO));
    }

    /**
     * 精选商品
     *
     * @param param
     * @return
     */
    @ApiOperation("精选商品")
    @PostMapping(value = "/boutique")
    public Response boutique(@ParamValid PageVO param) {
        Page<GoodsTaobaoModel> pageInfo = new Page<>(param.getPage(), param.getSize());
        return Response.success(goodsTaobaoService.getBoutique(pageInfo));
    }

    /**
     * 商品详情
     *
     * @param goodsDetailsVO
     * @return
     */
    @ApiOperation("商品详情")
    @PostMapping(value = "/details")
    public Response getDetails(@ParamValid GoodsDetailsVO goodsDetailsVO) {
        GoodsTaobaoDetailsDto goodsTaobao = goodsTaobaoService.getDetails(goodsDetailsVO);
        return Response.success(goodsTaobao);
    }
}
